import request from '@/utils/request'

export default {
  //添加、修改
  saveOrUpdateArticle(article) {
    return request({
      url: `/admin/article`,
      method: 'post',
      data: article
    })
  },
  //逻辑删除与恢复
  logicDelete(deleteVO) {
    return request({
      url: `/admin/article`,
      method: 'put',
      data: deleteVO
    })
  },
  //物理删除
  deleteArticles(idList) {
    return request({
      url: `/admin/article`,
      method: 'delete',
      data: idList.data
    })
  },
  //获取列表(前端)，只有id和name
  articleList() {
    return request({
      url: `articles`,
      method: 'get',
    })
  },
  //获取列表(后端)
  articleBackList(condition) {
    return request({
      url: `/admin/articles`,
      method: 'post',
      data: condition
    })
  },
  // 上传文章图片
  savaArticleImg(img) {
    return request({
      url: `/admin/article/images`,
      headers: { 'Content-Type': 'multipart/form-data' },
      method: 'post',
      data: img,
    })
  },
  // 通过id获取文章（后台）
  getBackArticleById(articleId) {
    return request({
      url: `/admin/article/${articleId}`,
      method: 'get',
    })
  },
  //置顶文章
  changeTop(article){
    return request({
      url: `/admin/article/top`,
      method: 'put',
      data: article
    })
  },
  //导出文章
  exportArticles(article){
    console.log("api:",article);
    return request({
      url: `/admin/article/export`,
      method: 'post',
      data: article
    })
  }
}